import React from 'react'
import { HashRouter,Redirect,Route,Switch } from 'react-router-dom'
import Login from '../views/login/Login'
import Details from '../views/news/Details'
import News from '../views/news/News'
import NewsSandBox from '../views/sandbox/NewsSandBox'
export default function IndexRounter() {
  return (
    <HashRouter>
      <Switch>
        <Route path="/login" component={Login} />
        <Route path="/news" component={News} />
        <Route path="/details/:id" component={Details} />
        <Route path="/" render={() =>
          localStorage.getItem('token')?
            <NewsSandBox></NewsSandBox> :
            <Redirect to="/login"/>
        }/>
      </Switch>
    </HashRouter>
  )
}